<template>
	<view class="page">
		<mescroll-uni @init="mescrollInit" top="24" @down="downCallback" :up="upOption" @up="upCallback"
			@emptyclick="emptyClick">
			<template v-for="(data, index) in dataList">
				<view class="items" @click="fenqi(data)">
					<view class="items_left">
						<img :src="data.photo" alt="" style="width: 100%;height: 100%;">
					</view>
					<view class="items_right">
						<view class="items_right_t">
							{{data.carTypeNum}}
						</view>
						<view class="items_right_b">
							<span>指导价:</span>
							<span v-if="data.minPrice!=data.maxPrice"
								style="color: #EB2223;margin-left: 5rpx;">￥{{data.minPrice}} - {{data.maxPrice}}</span>
							<span v-if="data.minPrice===data.maxPrice"
								style="color: #EB2223;margin-left: 5rpx;">￥{{data.minPrice}}</span>
						</view>
					</view>
				</view>
			</template>
		</mescroll-uni>

	</view>
</template>

<script>
	import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				id: null,
				Words: '', //搜索的关键字
				upOption: {
					noMoreSize: 10, //如果列表已无数据,可设置列表的总数量要大于半页才显示无更多数据;避免列表数据过少(比如只有一条数据),显示无更多数据会不好看; 默认10,
				},
				top: "24rpx",
				pager: {
					currentPage: 1,
					maxResultCount: 10
				},
				dataList: [],
			}
		},
		onLoad(pingpaiId) {
			this.getList(pingpaiId.pingpaiID)
			this.id = pingpaiId.pingpaiID
		},
		methods: {

			async getList() {

				//获取练习列表数据
				const res = await this.$post(`/biz/wxInstallment/getAllCarTypeByBrandId`, {
					current: this.pager.currentPage,
					size: this.pager.maxResultCount,
					brandId: this.id
				})
				if (res.data.data.total >= 0) {
					if (this.pager.currentPage == 1) {
						this.dataList = []
					}
					this.dataList = this.dataList.concat(res.data.data.records)
				}
				this.mescroll.endBySize(res.data.data.size, res.data.data.total)
			},
			/*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
			upCallback(page) {
				this.pager.currentPage = page.num; //在第几页
				this.pager.maxResultCount = page.size; //展示多少条数据
				this.getList()
			},
			downCallback(page) { // 下拉刷新
				this.mescroll.resetUpScroll();
			},
			fenqi(val) {
				var pages = getCurrentPages()
				console.log(pages,'pages');
				var prevPage = {}
				
				pages.forEach((items, index) => {
					if (items.route == "pages/ke_hu_duan/wo_de_shen_qing/shen_qing_fen_qi") {
						prevPage = pages[index]
						if (val.minPrice == val.maxPrice) {
							prevPage.$vm.form.carPrice = val.minPrice
						} else {
							prevPage.$vm.form.carPrice = `${val.minPrice} - ${val.maxPrice}`
						}
						prevPage.$vm.CarTypeTips = val.carTypeNum
						prevPage.$vm.form.cartypeId = val.id
						uni.navigateBack({
							delta: 2
						})
						return
					}
					if (items.route == "pages/che_dai_ji_suan_qi/che_dai_ji_suan_qi") {
						prevPage = pages[index]
						if (val.minPrice == val.maxPrice) {
							prevPage.$vm.form.carPrice = val.minPrice
							prevPage.$vm.chejia=val.minPrice
						} else {
							// prevPage.$vm.form.carPrice = `${val.minPrice} - ${val.maxPrice}`
							// prevPage.$vm.chejia=`${val.minPrice} - ${val.maxPrice}`
							
							prevPage.$vm.form.carPrice = val.minPrice
							prevPage.$vm.chejia = val.minPrice
						}
						prevPage.$vm.CarTypeTips = val.carTypeNum
						prevPage.$vm.form.cartypeId = val.id
						
						uni.navigateBack({
							delta: 2
						})
						return
					}
				})
			}

		}
	}
</script>

<style>
	.page {
		overflow-y: auto;
		width: 100%;
		height: 100vh;
		background-color: #fff;
	}

	.items {
		display: flex;
		align-items: center;
		justify-content: flex-start;
		width: 690rpx;
		height: 180rpx;
		margin: 0 auto 0;
		border-bottom: 2rpx solid #F4F4FA;
	}

	.items_left {
		width: 128rpx;
		height: 117rpx;
		margin: 0 50rpx 0 41rpx;
	}

	.items_right {
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: flex-start;
		flex-direction: column;
	}

	.items_right_t {
		font-size: 26rpx;
		font-family: 'PingFang SC-Regular, PingFang SC';
		font-weight: 400;
		color: #1A1824;
	}

	.items_right_b {
		font-size: 27rpx;
		font-family: 'PingFang SC-Regular, PingFang SC';
		font-weight: 400;
		color: #9D9D9D;
		margin-top: 8rpx;
	}
</style>